import request from "./request";

export const userService = {
  // 获取用户信息
  async getUserInfo() {
    return await request({
      url: "User/info",
      method: "GET",
    });
  },

  // 更新用户信息
  async updateUserInfo(data) {
    return await request({
      url: "User/info",
      method: "PUT",
      data,
    });
  },

  // 获取默认收货地址
  async getDefaultAddress() {
    return await request({
      url: 'Address/default',
      method: 'GET'
    });
  },

  // 获取收货地址列表
  async getAddressList() {
    return await request({
      url: 'Address/list',
      method: 'GET'
    });
  },

  // 微信登录（使用用户信息）
  async wxLogin(data) {
    return await request({
      url: "User/wxLogin",
      method: "POST",
      data: {
        code: data.code,
        userInfo: data.userInfo,
      },
    });
  },

  // 微信手机号登录
  async wxPhoneLogin(data) {
    return await request({
      url: "User/wxPhoneLogin",
      method: "POST",
      data: {
        code: data.code,
        encryptedData: data.encryptedData,
        iv: data.iv,
      },
    });
  },
};
